package ve.usb.ddp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import ve.usb.cohesion.runtime.CohesionAction;

import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import ve.usb.cohesion.runtime.HibernateUtil;
import ve.usb.ddp.hibernate.*;


/**
 * Manejo de elementos de la entidad PaiResolucion.<br>
 */
public class AccionesPaiResolucion extends CohesionAction {
    
/**
     * Called by Struts for the execution of action APreBuscar_paiResolucion.
     * Prepara la vista de selección de criterios de búsqueda para una entidad.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward APreBuscar_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"VBuscar_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            FPaiResolucionBuscar.clear(mapping, request);

            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action APreCrear_paiResolucion.
     * Prepara la vista de captura de datos de una entidad para realizar una inserción.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward APreCrear_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"VCrear_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            FPaiResolucion fFPaiResolucion = FPaiResolucion.clear(mapping, request);

             //Feed for combo listPai.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(ci, idPai) " + 
                "from Pai").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPai(list);
             }
             //Feed for combo listPaiEstudio.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(pais, idEstudio) " + 
                "from PaiEstudio").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPaiEstudio(list);
             }
             //Feed for combo listPaiApoderado.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(ci, idApoderado) " + 
                "from PaiApoderado").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPaiApoderado(list);
             }
             //Feed for combo listPaiPermisoNoRemunerado.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(informe_entregado, idPermiso_no_Remunerado) " + 
                "from PaiPermisoNoRemunerado").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPaiPermisoNoRemunerado(list);
             }
             //Feed for combo listPaiProrroga.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(otorgado, idProrroga) " + 
                "from PaiProrroga").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPaiProrroga(list);
             }
             //Feed for combo listPaiReintegro.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(fec_reintegro, idReintegro) " + 
                "from PaiReintegro").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPaiReintegro(list);
             }
             //Feed for combo listPaiRenunciaManutencion.
             {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
                (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
                "select new ve.usb.cohesion.runtime.Pair(monto_Anterior, idRenuncia_Manutencion) " + 
                "from PaiRenunciaManutencion").list();
              list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
              fFPaiResolucion.setListPaiRenunciaManutencion(list);
             }


            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action ABuscar_paiResolucion.
     * Captura los criterios de búsqueda y los fija en la sesión.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward ABuscar_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"APreListar_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            FPaiResolucionBuscar fFPaiResolucionBuscar = (FPaiResolucionBuscar)form;
            request.getSession().setAttribute("ABuscar_paiResolucion_campo", "fec_Resolucion");
            request.getSession().setAttribute("ABuscar_paiResolucion_valor", "%" + fFPaiResolucionBuscar.getFec_Resolucion() + "%");

            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action APreListar_paiResolucion.
     * Selecciona las entidades a ser listadas de acuerdo a los parámetros recibidos.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward APreListar_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"VListar_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            String crit = (String)request.getSession().getAttribute("ABuscar_paiResolucion_campo");
            java.util.List<PaiResolucion> list;
            if (crit==null) {
                list = (java.util.List<PaiResolucion>)s.createQuery("from PaiResolucion").list();
            } else {
                String valor = (String)request.getSession().getAttribute("ABuscar_paiResolucion_valor");
                list = (java.util.List<PaiResolucion>)
                   s.createQuery("from PaiResolucion where "+crit+" like :valor")
                    .setString("valor", valor).list();
                request.getSession().removeAttribute("ABuscar_paiResolucion_campo");
                request.getSession().removeAttribute("ABuscar_paiResolucion_valor");
            }
            request.setAttribute("L_PaiResolucion", list);
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getPai()!=null) paiResolucion.getPai().getCi();
            }
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getEstudio()!=null) paiResolucion.getEstudio().getPais();
            }
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getApoderado()!=null) paiResolucion.getApoderado().getCi();
            }
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getPermisoNoRemunerado()!=null) paiResolucion.getPermisoNoRemunerado().getInforme_entregado();
            }
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getProrroga()!=null) paiResolucion.getProrroga().getOtorgado();
            }
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getReintegro()!=null) paiResolucion.getReintegro().getFec_reintegro();
            }
            for (PaiResolucion paiResolucion:list) {
                if (paiResolucion.getRenunciaManutencion()!=null) paiResolucion.getRenunciaManutencion().getMonto_Anterior();
            }


            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action APre_paiResolucion.
     * Prepara la vista de actualización de una entidad.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward APre_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"V_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            Long idResolucion = lookup_Long(request, "idResolucion");
            
            FPaiResolucion fFPaiResolucion = FPaiResolucion.clear(mapping, request);
            PaiResolucion paiResolucion = (PaiResolucion)s.load(PaiResolucion.class, idResolucion);
            fFPaiResolucion.setIdResolucion(paiResolucion.getIdResolucion());
            if (paiResolucion.getPai()!=null) {
                fFPaiResolucion.setPai(paiResolucion.getPai().getIdPai());
            } else {
                fFPaiResolucion.setPai(0L);
            }
            fFPaiResolucion.setFec_Resolucion(paiResolucion.getFec_Resolucion().toString());
            fFPaiResolucion.setNum_InformeDDP(paiResolucion.getNum_InformeDDP());
            fFPaiResolucion.setObservacion(paiResolucion.getObservacion());
            fFPaiResolucion.setNum_Resolucion(paiResolucion.getNum_Resolucion());
            if (paiResolucion.getEstudio()!=null) {
                fFPaiResolucion.setEstudio(paiResolucion.getEstudio().getIdEstudio());
            } else {
                fFPaiResolucion.setEstudio(0L);
            }
            if (paiResolucion.getApoderado()!=null) {
                fFPaiResolucion.setApoderado(paiResolucion.getApoderado().getIdApoderado());
            } else {
                fFPaiResolucion.setApoderado(0L);
            }
            if (paiResolucion.getPermisoNoRemunerado()!=null) {
                fFPaiResolucion.setPermisoNoRemunerado(paiResolucion.getPermisoNoRemunerado().getIdPermiso_no_Remunerado());
            } else {
                fFPaiResolucion.setPermisoNoRemunerado(0L);
            }
            if (paiResolucion.getProrroga()!=null) {
                fFPaiResolucion.setProrroga(paiResolucion.getProrroga().getIdProrroga());
            } else {
                fFPaiResolucion.setProrroga(0L);
            }
            if (paiResolucion.getReintegro()!=null) {
                fFPaiResolucion.setReintegro(paiResolucion.getReintegro().getIdReintegro());
            } else {
                fFPaiResolucion.setReintegro(0L);
            }
            if (paiResolucion.getRenunciaManutencion()!=null) {
                fFPaiResolucion.setRenunciaManutencion(paiResolucion.getRenunciaManutencion().getIdRenuncia_Manutencion());
            } else {
                fFPaiResolucion.setRenunciaManutencion(0L);
            }

            //Feed for combo listPai.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(ci, idPai) " + 
               "from Pai").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPai(list);
            }
            //Feed for combo listPaiEstudio.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(pais, idEstudio) " + 
               "from PaiEstudio").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiEstudio(list);
            }
            //Feed for combo listPaiApoderado.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(ci, idApoderado) " + 
               "from PaiApoderado").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiApoderado(list);
            }
            //Feed for combo listPaiPermisoNoRemunerado.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(informe_entregado, idPermiso_no_Remunerado) " + 
               "from PaiPermisoNoRemunerado").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiPermisoNoRemunerado(list);
            }
            //Feed for combo listPaiProrroga.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(otorgado, idProrroga) " + 
               "from PaiProrroga").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiProrroga(list);
            }
            //Feed for combo listPaiReintegro.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(fec_reintegro, idReintegro) " + 
               "from PaiReintegro").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiReintegro(list);
            }
            //Feed for combo listPaiRenunciaManutencion.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(monto_Anterior, idRenuncia_Manutencion) " + 
               "from PaiRenunciaManutencion").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiRenunciaManutencion(list);
            }

            for (PaiRemuneracion _PaiRemuneracion : paiResolucion.getRemuneracion()) {
                Hibernate.initialize(_PaiRemuneracion.getResolucion());
            }
            request.setAttribute("L_PaiRemuneracion", paiResolucion.getRemuneracion());
            for (PaiEstatus _PaiEstatus : paiResolucion.getEstatus()) {
                Hibernate.initialize(_PaiEstatus.getResolucion());
            }
            request.setAttribute("L_PaiEstatus", paiResolucion.getEstatus());

            request.getSession().setAttribute("idResolucion", idResolucion);
            request.getSession().setAttribute("idResolucion_super", idResolucion);

            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action AAct_paiResolucion.
     * Registro de actualizaciones de una entidad.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward AAct_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"V_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            FPaiResolucion fFPaiResolucion = (FPaiResolucion)form;
            PaiResolucion paiResolucion = (PaiResolucion)s.load(PaiResolucion.class, fFPaiResolucion.getIdResolucion());
            if (fFPaiResolucion.getPai()==0) paiResolucion.setPai(null);
            else if ((paiResolucion.getPai()==null) ||
                    (paiResolucion.getPai().getIdPai()!=fFPaiResolucion.getPai())) {
                Pai __obj = (Pai)s.load(Pai.class, fFPaiResolucion.getPai());
                paiResolucion.setPai(__obj);
            }
            paiResolucion.setFec_Resolucion(new ve.usb.cohesion.runtime.LocalDate(fFPaiResolucion.getFec_Resolucion()));
            paiResolucion.setNum_InformeDDP(fFPaiResolucion.getNum_InformeDDP());
            paiResolucion.setObservacion(fFPaiResolucion.getObservacion());
            paiResolucion.setNum_Resolucion(fFPaiResolucion.getNum_Resolucion());
            if (fFPaiResolucion.getEstudio()==0) paiResolucion.setEstudio(null);
            else if ((paiResolucion.getEstudio()==null) ||
                    (paiResolucion.getEstudio().getIdEstudio()!=fFPaiResolucion.getEstudio())) {
                PaiEstudio __obj = (PaiEstudio)s.load(PaiEstudio.class, fFPaiResolucion.getEstudio());
                paiResolucion.setEstudio(__obj);
            }
            if (fFPaiResolucion.getApoderado()==0) paiResolucion.setApoderado(null);
            else if ((paiResolucion.getApoderado()==null) ||
                    (paiResolucion.getApoderado().getIdApoderado()!=fFPaiResolucion.getApoderado())) {
                PaiApoderado __obj = (PaiApoderado)s.load(PaiApoderado.class, fFPaiResolucion.getApoderado());
                paiResolucion.setApoderado(__obj);
            }
            if (fFPaiResolucion.getPermisoNoRemunerado()==0) paiResolucion.setPermisoNoRemunerado(null);
            else if ((paiResolucion.getPermisoNoRemunerado()==null) ||
                    (paiResolucion.getPermisoNoRemunerado().getIdPermiso_no_Remunerado()!=fFPaiResolucion.getPermisoNoRemunerado())) {
                PaiPermisoNoRemunerado __obj = (PaiPermisoNoRemunerado)s.load(PaiPermisoNoRemunerado.class, fFPaiResolucion.getPermisoNoRemunerado());
                paiResolucion.setPermisoNoRemunerado(__obj);
            }
            if (fFPaiResolucion.getProrroga()==0) paiResolucion.setProrroga(null);
            else if ((paiResolucion.getProrroga()==null) ||
                    (paiResolucion.getProrroga().getIdProrroga()!=fFPaiResolucion.getProrroga())) {
                PaiProrroga __obj = (PaiProrroga)s.load(PaiProrroga.class, fFPaiResolucion.getProrroga());
                paiResolucion.setProrroga(__obj);
            }
            if (fFPaiResolucion.getReintegro()==0) paiResolucion.setReintegro(null);
            else if ((paiResolucion.getReintegro()==null) ||
                    (paiResolucion.getReintegro().getIdReintegro()!=fFPaiResolucion.getReintegro())) {
                PaiReintegro __obj = (PaiReintegro)s.load(PaiReintegro.class, fFPaiResolucion.getReintegro());
                paiResolucion.setReintegro(__obj);
            }
            if (fFPaiResolucion.getRenunciaManutencion()==0) paiResolucion.setRenunciaManutencion(null);
            else if ((paiResolucion.getRenunciaManutencion()==null) ||
                    (paiResolucion.getRenunciaManutencion().getIdRenuncia_Manutencion()!=fFPaiResolucion.getRenunciaManutencion())) {
                PaiRenunciaManutencion __obj = (PaiRenunciaManutencion)s.load(PaiRenunciaManutencion.class, fFPaiResolucion.getRenunciaManutencion());
                paiResolucion.setRenunciaManutencion(__obj);
            }


            //Feed for combo listPai.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(ci, idPai) " + 
               "from Pai").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPai(list);
            }
            //Feed for combo listPaiEstudio.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(pais, idEstudio) " + 
               "from PaiEstudio").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiEstudio(list);
            }
            //Feed for combo listPaiApoderado.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(ci, idApoderado) " + 
               "from PaiApoderado").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiApoderado(list);
            }
            //Feed for combo listPaiPermisoNoRemunerado.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(informe_entregado, idPermiso_no_Remunerado) " + 
               "from PaiPermisoNoRemunerado").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiPermisoNoRemunerado(list);
            }
            //Feed for combo listPaiProrroga.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(otorgado, idProrroga) " + 
               "from PaiProrroga").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiProrroga(list);
            }
            //Feed for combo listPaiReintegro.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(fec_reintegro, idReintegro) " + 
               "from PaiReintegro").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiReintegro(list);
            }
            //Feed for combo listPaiRenunciaManutencion.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(monto_Anterior, idRenuncia_Manutencion) " + 
               "from PaiRenunciaManutencion").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiRenunciaManutencion(list);
            }

            for (PaiRemuneracion _PaiRemuneracion : paiResolucion.getRemuneracion()) {
                Hibernate.initialize(_PaiRemuneracion.getResolucion());
            }
            request.setAttribute("L_PaiRemuneracion", paiResolucion.getRemuneracion());
            for (PaiEstatus _PaiEstatus : paiResolucion.getEstatus()) {
                Hibernate.initialize(_PaiEstatus.getResolucion());
            }
            request.setAttribute("L_PaiEstatus", paiResolucion.getEstatus());

            request.getSession().setAttribute("idResolucion", paiResolucion.getIdResolucion());
            request.getSession().setAttribute("idResolucion_super", paiResolucion.getIdResolucion());

            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        if (salida==0) {
          request.setAttribute("msg",
            getResources(request).getMessage("AAct_paiResolucion.msg0"));
        }

        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action AElim_paiResolucion.
     * Elimina la entidad seleccionada.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward AElim_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"APreListar_paiResolucion", "V_paiResolucion", };
        final int SALIDA_0 = 0;
        final int SALIDA_1 = 1;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            Long idResolucion = lookup_Long(request, "idResolucion");
            PaiResolucion paiResolucion = (PaiResolucion)s.load(PaiResolucion.class, idResolucion);
            s.delete(paiResolucion);
            try {
                s.flush();
            } catch (Exception ex1) {
                ex1.printStackTrace();
                salida = SALIDA_1;
            }

            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        if (salida==0) {
          request.setAttribute("msg",
            getResources(request).getMessage("AElim_paiResolucion.msg0"));
        }
        if (salida==1) {
          request.setAttribute("msg",
            getResources(request).getMessage("AElim_paiResolucion.msg1"));
        }

        return mapping.findForward(SALIDAS[salida]);
    }

/**
     * Called by Struts for the execution of action ACrear_paiResolucion.
     * Registro de la creación de una PaiResolucion.<br>
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @return The Struts name of the following step.
     * @throws java.lang.Exception For untreated exceptions. 
     * These exceptios will normally be treated with 
     * the default exception action.
     */
    public ActionForward ACrear_paiResolucion(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        //Salidas
        final String[] SALIDAS = {"V_paiResolucion", };
        final int SALIDA_0 = 0;

        int salida = SALIDA_0;
//Checking for actors administrador
            if (!CohesionActor.checkActor(request, 1)) {
                return mapping.findForward(CohesionActor.SALIDA_ACTOR);
            }
        Session s = HibernateUtil.getCurrentSession();
        Transaction tr = s.beginTransaction();
        try {
            FPaiResolucion fFPaiResolucion = (FPaiResolucion)form;
            PaiResolucion paiResolucion = new PaiResolucion();
            if (fFPaiResolucion.getPai()==0) paiResolucion.setPai(null);
            else {
                Pai __obj = (Pai)s.load(Pai.class, fFPaiResolucion.getPai());
                paiResolucion.setPai(__obj);
            }
            paiResolucion.setFec_Resolucion(new ve.usb.cohesion.runtime.LocalDate(fFPaiResolucion.getFec_Resolucion()));
            paiResolucion.setNum_InformeDDP(fFPaiResolucion.getNum_InformeDDP());
            paiResolucion.setObservacion(fFPaiResolucion.getObservacion());
            paiResolucion.setNum_Resolucion(fFPaiResolucion.getNum_Resolucion());
            if (fFPaiResolucion.getEstudio()==0) paiResolucion.setEstudio(null);
            else {
                PaiEstudio __obj = (PaiEstudio)s.load(PaiEstudio.class, fFPaiResolucion.getEstudio());
                paiResolucion.setEstudio(__obj);
            }
            if (fFPaiResolucion.getApoderado()==0) paiResolucion.setApoderado(null);
            else {
                PaiApoderado __obj = (PaiApoderado)s.load(PaiApoderado.class, fFPaiResolucion.getApoderado());
                paiResolucion.setApoderado(__obj);
            }
            if (fFPaiResolucion.getPermisoNoRemunerado()==0) paiResolucion.setPermisoNoRemunerado(null);
            else {
                PaiPermisoNoRemunerado __obj = (PaiPermisoNoRemunerado)s.load(PaiPermisoNoRemunerado.class, fFPaiResolucion.getPermisoNoRemunerado());
                paiResolucion.setPermisoNoRemunerado(__obj);
            }
            if (fFPaiResolucion.getProrroga()==0) paiResolucion.setProrroga(null);
            else {
                PaiProrroga __obj = (PaiProrroga)s.load(PaiProrroga.class, fFPaiResolucion.getProrroga());
                paiResolucion.setProrroga(__obj);
            }
            if (fFPaiResolucion.getReintegro()==0) paiResolucion.setReintegro(null);
            else {
                PaiReintegro __obj = (PaiReintegro)s.load(PaiReintegro.class, fFPaiResolucion.getReintegro());
                paiResolucion.setReintegro(__obj);
            }
            if (fFPaiResolucion.getRenunciaManutencion()==0) paiResolucion.setRenunciaManutencion(null);
            else {
                PaiRenunciaManutencion __obj = (PaiRenunciaManutencion)s.load(PaiRenunciaManutencion.class, fFPaiResolucion.getRenunciaManutencion());
                paiResolucion.setRenunciaManutencion(__obj);
            }

            s.save(paiResolucion);
            s.flush();
            fFPaiResolucion.setIdResolucion(paiResolucion.getIdResolucion());

            //Feed for combo listPai.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(ci, idPai) " + 
               "from Pai").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPai(list);
            }
            //Feed for combo listPaiEstudio.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(pais, idEstudio) " + 
               "from PaiEstudio").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiEstudio(list);
            }
            //Feed for combo listPaiApoderado.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(ci, idApoderado) " + 
               "from PaiApoderado").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiApoderado(list);
            }
            //Feed for combo listPaiPermisoNoRemunerado.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(informe_entregado, idPermiso_no_Remunerado) " + 
               "from PaiPermisoNoRemunerado").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiPermisoNoRemunerado(list);
            }
            //Feed for combo listPaiProrroga.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(otorgado, idProrroga) " + 
               "from PaiProrroga").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiProrroga(list);
            }
            //Feed for combo listPaiReintegro.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(fec_reintegro, idReintegro) " + 
               "from PaiReintegro").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiReintegro(list);
            }
            //Feed for combo listPaiRenunciaManutencion.
            {java.util.List<ve.usb.cohesion.runtime.Pair> list = 
               (java.util.List<ve.usb.cohesion.runtime.Pair>)s.createQuery(
               "select new ve.usb.cohesion.runtime.Pair(monto_Anterior, idRenuncia_Manutencion) " + 
               "from PaiRenunciaManutencion").list();
             list.add(0,new ve.usb.cohesion.runtime.Pair("Ninguna", 0));
             fFPaiResolucion.setListPaiRenunciaManutencion(list);
            }

            request.getSession().setAttribute("idResolucion", paiResolucion.getIdResolucion());
            request.getSession().setAttribute("idResolucion_super", paiResolucion.getIdResolucion());

            tr.commit();

        } catch (Exception ex) {
            tr.rollback();
            throw ex;
        } finally {
            try { s.close(); } catch (Exception ex2) {}
        }
        if (salida==0) {
          request.setAttribute("msg",
            getResources(request).getMessage("ACrear_paiResolucion.msg0"));
        }

        return mapping.findForward(SALIDAS[salida]);
    }



}